﻿

namespace Risk.Model
{
    public class Throw
    {
        public Throw(int nrOfAttackerDice, int nrOfDefenderDice)
        {
            Dice = RandomDiceResult.GenerateSortedArray(nrOfAttackerDice);
            DefendingDice = RandomDiceResult.GenerateSortedArray(nrOfDefenderDice);
            int minimumDice = nrOfDefenderDice < nrOfAttackerDice ? nrOfDefenderDice : nrOfAttackerDice;
            for (int i = 0; i < minimumDice; i++)
            {
                if (Dice[i] > DefendingDice[i])
                    DefendersDead++;
                else
                    AttackersDead++;
            }
        }
        /// <summary>
        /// The outcomes of the attack dice
        /// </summary>
        public int[] Dice { get; set; }

        /// <summary>
        /// The outcomes of the defending dice
        /// </summary>
        public int[] DefendingDice { get; set; }

        /// <summary>
        /// Was there a victory: have all the troops in the defending region been defeated
        /// </summary>
        public bool Victory { get; set; }
        public int AttackersDead { get; private set; }
        public int DefendersDead { get; private set; }
    }
}
